import request from '@/utils/request'

/**
 * 获取角色列表
 * @param {*} page 当前页
 * @param {*} pagesize 每页页容量
 * @returns
 */
export const getRoleListApi = (page, pagesize) => {
  return request({
    url: '/sys/role',
    params: {
      page,
      pagesize
    }
  })
}

// export const getRoleListApi = (page, pagesize) => request.get('/sys/role', { params: { page, pagesize }})

// 删除
export const delRoleApi = (id) => {
  return request({
    url: `/sys/role/${id}`,
    method: 'DELETE'
  })
}

// 新增角色
export const addRoleApi = (data) => {
  return request({
    url: '/sys/role',
    method: 'POST',
    data
  })
}

// 获取修改的数据
export const getEditRoleApi = (id) => {
  return request({
    url: `/sys/role/${id}`,
    method: 'get'
  })
}
// 重新上传修改过的信息
export const editRoleApi = (data) => {
  return request({
    url: `/sys/role/${data.id}`,
    method: 'put',
    data
  })
}

// 获取公司信息
export const getCompanyInfoApi = (id) => {
  return request({
    url: `/company/${id}`,
    method: 'get'
  })
}

/**
 * 给角色分配权限
 * @param {*} data 所需参数
 * @returns
 */
export const assignPermApi = data => {
  return request({
    url: '/sys/role/assignPrem',
    method: 'put',
    data
  })
}
